# ------------------------------ 
# 'execute scripts on BigRed3 + Carbonate (for MI)
# ------------------------------
code_path = "/N/project/suicide_study/code/multilevel-suicide/code/workflow/pnas_replication"

setwd(code_path)

list_model = c("mi","logit")
list_model_version = 1:6

# for marginal effects
for (model in list_model) {
	for (model_version in list_model_version){
		if (model == 'logit'){
			bash_script = '8_stata_run_bash_logit.sh'			
		} else {
			bash_script = '8_stata_run_bash_cb.sh'			
		}
		system(paste0('qsub -N ',paste0(model,model_version),
			' -v ',
			paste0(c('model=',model,',model_version=',model_version),collapse=''),
			' ',bash_script))
	}	
}

# for comparison between individual-only and contextual-only models
list_model = c("mi","logit")

# for marginal effects
for (model in list_model) {
	if (model == 'logit') {
		list_model_version = 7:8
	} else {
		list_model_version = 9:10
	}
	for (model_version in list_model_version){
		if (model == 'logit'){
			bash_script = '8_stata_run_bash_logit.sh'			
		} else {
			bash_script = '8_stata_run_bash_cb.sh'			
		}
		system(paste0('qsub -N ',paste0(model,model_version),
			' -v ',
			paste0(c('model=',model,',model_version=',model_version),collapse=''),
			' ',bash_script))
	}	
}

# for appendix table
system(paste0('qsub -N ','tabappendix',' 8_stata_run_appendix_cb.sh'))


